package app.backend.service.impl;

import app.backend.entity.BizAnnouncement;
import app.backend.entity.BizCarousel;
import app.backend.mapper.BizAnnouncementMapper;
import app.backend.service.BizAnnouncementService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
@Slf4j
public class BizAnnouncementServiceImpl extends ServiceImpl<BizAnnouncementMapper, BizAnnouncement> implements BizAnnouncementService {

    @Override
    public List<BizAnnouncement> getEnabledAnnouncements() {
        QueryWrapper<BizAnnouncement> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(BizAnnouncement::getDeleteFlag, "NOT_DELETE")
            .eq(BizAnnouncement::getIsEnable, "1")  // 状态为开启
            .orderByAsc(BizAnnouncement::getSortOrder);  // 按排序字段升序
        return list(queryWrapper);
    }
}

